
#ifndef METHODFORMAT_H
#define METHODFORMAT_H

#include <BMap>
#include <BFont>
#include <BRange>
#include <BTreeItem>
#include <BTextFormat>

using namespace BWE;

class MethodFormat : public BTextFormat
{
public:
	struct Item
	{
		BRect			rect;
		BFontHolder		font;
		BColor			color;
		BRange			range;
	};
	typedef BMap<int, Item>		ItemMap;

public:
	MethodFormat(const BString& name = BString());
	~MethodFormat();

	virtual void styled(const BStyle* style) override;
	virtual void changed(const BString& text) override;

	virtual const BColor* color(int pos) const;

protected:
	int strideBlock(const BString& text, int pos);
	void formatKeywords(const BString& text, int begin, int end);

protected:
	void slotAssetChanged(BObject* object, const BValue& value);

private:
	BTreeItem*				_treeItem;
	bool					_dirty;
	BMap<int, Item>			_itemMap;
	BMap<BString, BColor>	_colorMap;
};

#endif
